#!/bin/bash
HOST=$1
case $HOST in
{% for instance in aws_ec2_instance_data %}

  {{ instance[0] }})
    IP={{ instance[1] }}
    ;;
{% endfor %}

  *)
    echo "Usage: ./aws-ssh.sh <host>"
    echo "  Valid hosts: {{ aws_instances.keys() | join(', ') }}"
    exit 1
    ;;

esac

ssh_args="-o UserKnownHostsFile={{ aws_k8s_ssh_dir }}/known_hosts_aws_ansible_k8s"
ssh_args+=" -i {{ aws_k8s_ssh_dir }}/id_rsa_aws_ansible_k8s"
ssh $ssh_args ubuntu@$IP
